package com.ynny.list01.service;

import com.ynny.list01.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentService {
    ArrayList<Student> students = new ArrayList<>();
    Scanner scanner = new Scanner(System.in);


    public void printStudent() {
        for (int i = 0; i < students.size(); i++) {
            Student stu = students.get(i);
            System.out.println(stu.getName() + "----" + stu.getAge());
        }

    }

    public void add() {
        System.out.println("请输入学生的姓名");
        String name = scanner.next();
        System.out.println("请输入学生的年龄");
        int age = scanner.nextInt();
        Student student = new Student();
        student.setName(name);
        student.setAge(age);
        students.add(student);
        System.out.println(students);
    }

}
